package com.arcsoft.api.base.util;

import lombok.Getter;


@Getter
public class Result<T> {
    private int code;
    private String message;
    private Object data;

    public Result(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result(200, "Success", null);
    }

    public static <T> Result<T> success(T data) {
        return new Result(200, "Success", data);
    }

    public static <T> Result<T> fail(T data, String message) {
        return new Result(500, message, data);
    }

    public static <T> Result<T> fail(T data, String message, int code) {
        return new Result(code, message, data);
    }

    public static <T> Result<T> fail(String message, int code) {
        return new Result(code, message, null);
    }

    public static <T> Result<T> fail(String message) {
        return new Result(500, message, null);
    }
}
